﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Xuanren_FrontEnd.Model;

namespace Xuanren_FrontEnd.Controllers
{
    public class ProductController : Controller
    {
        private XuanrenTherapyEntities db = new XuanrenTherapyEntities();
        // GET: Product
        public ActionResult ProductList(int id)
        {
            //商品列表
            ViewBag.ProductList = db.Product.Where(x => x.category_id == id && x.status == "1").
                                             Take(8).OrderByDescending(p => p.create_time);
            //商品分类列表
            ViewBag.ProductTypeList=db.Category.Where(x => true);

            //分类ID
            ViewBag.typeId = id;
            return View();
        }

        public ActionResult ProductDetail(int id)
        {
            //根据ID查询商品
            Product product = db.Product.SingleOrDefault(x=>x.id==id);

            //商品分类列表
            ViewBag.ProductTypeList = db.Category.Where(x => true);


            ViewBag.ProductTypeId = product.category_id;
            return View(product);
        }
    }
}